<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<%-- <%@include file="edit.jsp"%> --%>
<html>
<head>
<script type="text/javascript">
	$(function() {
		$('#enabled').radiobox({name:'entity.enabled',value:'${item.enabled}',data:[[true,'有效'],[false,'无效']]});
		$('#gender').radiobox({name:'entity.gender',value:'${item.gender}',data:[['1','男'],['3','女'],['5','其他']]});
		$('#combobox_type').combobox("setValue","${item.type}");
		$('#iUserType').combobox({
		    data:$codelist('userType'),editable:false,width:180
		});
		$('#toolbar').toolbar({buttons:[
			{name:'save',iconCls:'icon-save',text:'保存'}
	  	],handler:handler});
		
		$("#upload_headurl").on("click",function(){
			toDeploy("show_head","上传头像");
		});
		$("#upload_poster").on("click",function(){
			toDeploy("show_poster","上传海报");
		});
		
	});
	function handler() {
		switch(this.name) {
			case 'save': toSave();break;
		}
	}
	//添加界面的附件管理
	function toDeploy(item,title){
		showUpload({title:title
			,options:{
				filters:{
					mime_types: [{title : title, extensions : "jpg,png"}]
				},
				multi_selection: false ,
				 init:{
					 FileUploaded:function(uploader,file,responseObject){
						 var response = responseObject.response;
						 var json = eval('(' + response + ')');
						 var data = json.data;
						 var path = data.fileUrl;
						 showImg(item,path)
					 }
				},
				complete:function(){
					top.$ok('上传成功');
				}
			}
		});
	}
	function showImg(item,path){
		if(item == 'show_poster'){
			$("#input_poster").val(path);  //完成后更新已上传的文件列表
			$("#img_show_poster").attr("src",path);
		}else {
			$("#input_headurl").val(path);  //完成后更新已上传的文件列表
			$("#img_show_headUrl").attr("src",path);
		}
	}
	
	function toSave(){
		$.messager.progress({title:'系统提示',text:'数据处理中，请耐心等待...'});
		$.submit('#dataform',function(r) {
			$.messager.progress('close');
			if(r.code<0) return $alert(r.msg);
			top.$prompt('保存成功');
			top.$window.close(window,1,null);
		});
	}
	
</script>
</head>
<body>
	<div id="toolbar" class="toolbar" ></div>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',border:false">
			<form id="dataform" action="edit" method="post">
				<input type="hidden" name="entity.id" value="${item.id }" />
				<input type="hidden" name="entity.pid" value="0" />
				<input type="hidden" name="entity.point" value="${item.point }" />
				<input id="input_headurl" type="hidden" name="entity.headurl" value="${item.headurl }" />
				<table class="form-tbl">
					<tr class="form-tr">
						<th class="form-th">用户名:</th>
						<td class="form-td">
							<input name="entity.username" value="${item.username }" class="easyui-textbox" data-options="editable:false" style="width:170px;" />
						</td>
						<th class="form-th">昵称:</th>
						<td class="form-td">
							<input type="text" name="entity.nickname" value="${item.nickname }" class="form-text" style="width:170px;" />
						</td>
					</tr>
					<%-- <tr class="form-tr">
						<th class="form-th">密码:</th>
						<td class="form-td">
							<input type="text" name="entity.password" value="${item.password }" class="form-text" style="width:170px;" />
						</td>
						<th class="form-th">用户类型:</th>
						<td class="form-td">
							<input id="iUserType" name=item.type value="${item.type }" class="form-text" style="width:170px;" />
							<select id="combobox_type" class="easyui-combobox"name=entity.type value="${item.type }" style="width:200px;">
								<option value="1">管理员</option>
								<option value="3">普通用户</option>
								<option value="5">大咖用户</option>
							</select>
						</td>
					</tr> --%>
					<tr class="form-tr">
						<th class="form-th">手机号码:</th>
						<td class="form-td">
							<input id="phoneNumber" name=entity.phoneNumber value="${item.phoneNumber }" class="form-text" style="width:170px;" />
						</td>
						<th class="form-th">性别:</th>
						<td class="form-td">
							<%-- <input id="gender" name=item.gender value="${item.gender }" class="form-text" style="width:170px;" /> --%>
							<div id="gender"></div>
						</td>
					</tr>
					<tr class="form-tr">
						<th class="form-th">邮箱:</th>
						<td class="form-td">
							<input id="email" name=entity.email value="${item.email }" class="form-text" style="width:170px;" />
						</td>
						<th class="form-th">是否启用:</th>
						<td class="form-td">
							<div id="enabled"></div>
						</td>
					</tr>
 					
					<tr class="form-tr">
						<th class="form-th">擅长领域:</th>
						<td class="form-td" colspan="3">
							<input id="profession" name=entity.profession value="${item.profession }" class="easyui-textbox" data-options="multiline:true" style="width:100%;" />
						</td>
					</tr>
					<tr class="form-tr">
						<th class="form-th">读者对话:</th>
						<td class="form-td" colspan="3">
							<input id="speack" name=entity.speack value="${item.speack }" class="easyui-textbox" data-options="multiline:true" style="width:100%;height: 80px;" />
						</td>
					</tr>
					
					<tr class="form-tr">
						<th class="form-th">简介:</th>
						<td class="form-td" colspan="3">
							<input id="description" name=entity.description value="${item.description }" class="easyui-textbox" data-options="multiline:true" style="width:100%;height: 100px;" />
						</td>
					</tr>
					<tr class="form-tr">
						<th class="form-th">头像:</th>
						<td id="td_headurl">
							<input type="button" value="上传" id="upload_headurl">
						</td>
					</tr>
					<tr class="form-tr">
						<td id="show_head" class="form-td" colspan="4" style="height: 100px;">
							<img id="img_show_headUrl" alt="头像" src="${item.headurl }">
						</td>
					</tr>
					<tr class="form-tr">
						<th class="form-th">个人宣传海报:</th>
						<td id="td_poster">
							<input id="input_poster" type="hidden" name="entity.poster" value="${item.poster }">
							<input type="button" value="上传" id="upload_poster">
						</td>
					</tr>
					<tr class="form-tr">
						<td id="show_poster" class="form-td" colspan="4" style="height: 100px;">
							<img id="img_show_poster" alt="个人海报" src="${item.poster }">
						</td>
					</tr>
				</table>
			</form>
			
		</div>
	</div>
</body>
</html>